﻿var fs = require("fs");
var pako = require('pako');
var path = require('path')

var encode = function(fromDir) {
	var obj = {};
	var files = fs.readdirSync(fromDir);
	files.forEach(function(fileName){
		var fromPath = path.join(path.resolve(fromDir),fileName);
		var txt = fs.readFileSync(fromPath, {encoding: 'utf8'});
		
		var arr = fileName.split(".");
		var key = arr[0].toLowerCase() + "_" + arr[1];
		
		obj[key] = txt;
	})
	
	const contents = pako.deflate(JSON.stringify(obj));
	fs.writeFileSync("pakogame.cfg", contents);
}

encode("gameCfg/")